// src/main/java/com/yin/waimai/model/LogisticsTrace.java
package com.yin.waimai.model;

import com.yin.waimai.enums.LogisticsStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed; // 确保导入
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field; // 如果要用 @Field，确保导入

import java.time.LocalDateTime;

/**
 * 物流轨迹记录 (MongoDB Document)
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Document(collection = "logistics_traces")
public class LogisticsTrace {

    @Id
    private String id;

    @Indexed // 为订单的内部ID创建索引，便于查询
    @Field("order_id") // 与 Order 表的 _id 关联
    private String orderId;

    @Indexed // 通常也需要根据业务订单号查询轨迹
    @Field("order_number") // 新增字段，对应订单的业务编号
    private String orderNumber; // <--- 添加这个字段

    @Field("timestamp")
    private LocalDateTime timestamp;

    @Field("location")
    private String location;

    @Field("operator")
    private String operator;

    @Field("status") // 存储枚举的名称或自定义转换
    private LogisticsStatus status;

    @Field("description")
    private String description;
}